package com.superyee.commonlib.videoplayer.controller;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.dueeeke.videoplayer.controller.BaseVideoController;

/**
 * 仿抖音控制组件
 */
public class TikTokController extends BaseVideoController {


    private ImageView thumb;
    private TikTokView mTikTokView;

    public TikTokController(@NonNull Context context, boolean enableGesture) {
        super(context);
        addComponent();
        if (enableGesture) {
            mTikTokView.enableGesture(enableGesture);
        }
    }

    public TikTokController(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        addComponent();
    }

    public TikTokController(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        addComponent();
    }

    private void addComponent() {
        mTikTokView = new TikTokView(getContext());
        addControlComponent(mTikTokView, false);
        thumb = mTikTokView.getThumb();
    }

    public ImageView getThumb() {
        return thumb;
    }

    @Override
    protected int getLayoutId() {
        return 0;
    }


    @Override
    public boolean showNetWarning() {
        //不显示移动网络播放警告
        return false;
    }


    /**
     * 监听屏幕左滑打开新的activity
     *
     * @param listener
     */
    public void setOnNextPageListener(OnClickListener listener) {
        if (mTikTokView != null) {
            mTikTokView.setOnNextPageListener(listener);
        }
    }


}
